<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>微信应用管理服务平台</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/echarts/echarts.js"/>
</head>
<body>
<div class="wrap-container welcome-container">
    <div class="row">
        <!--昨日收益信信息开始-->
        <div class="welcome-left-container col-lg-9 marb10">
            <div class="panel area-pad">
                <div class="area-tit">校园资讯信息</div>
                <div class="four-area-menu">
                    <ul>
                        <li class="menu-bg-one">
                            <div class="menu-tit">通知公告</div>
                            <div class="menu-data"><span>条</span></div>
                            <div class="tmpic-bg"><img src="${s.base}/images/bar01.png"></div>
                        </li>
                        <li class="menu-bg-two">
                            <div class="menu-tit">讲座信息</div>
                            <div class="menu-data"><span>条</span></div>
                            <div class="tmpic-bg"><img src="${s.base}/images/bar03.png"></div>
                        </li>
                        <li class="menu-bg-thr">
                            <div class="menu-tit">失物招领</div>
                            <div class="menu-data"><span>条</span></div>
                            <div class="tmpic-bg"><img src="${s.base}/images/bar02.png"></div>
                        </li>
                        <li class="menu-bg-four">
                            <div class="menu-tit">招生信息</div>
                            <div class="menu-data"><span>条</span></div>
                            <div class="tmpic-bg"><img src="${s.base}/images/bar04.png"></div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!--昨日收益信信息结束-->
        <!--日历开始-->
        <div class="welcome-left-container col-lg-3 marb10">
            <div class="panel area-pad">
                <div class="area-tit div-calendar">日历</div>
            </div>
        </div>
        <!--日历结束-->
        <div class="welcome-left-container col-lg-9 marb10" style=" padding-left:0; padding-right:0;">
            <div class="welcome-left-container col-lg-12">
                <div class="panel area-pad">
                    <div class="area-tit">资产报修信息</div>
                    <div id="asset" style="width:100%;height:308px;"></div>
                </div>
            </div>
        </div>
        <!--登录日志开始-->
        <div class="welcome-left-container col-lg-3 marb10">
            <div class="panel area-pad">
                <div class="area-tit">登录日志</div>
                <div class="loginLog-sm">
                    <ul></ul>
                </div>
            </div>
        </div>
        <!--登录日志结束-->
        <div class="welcome-left-container col-lg-9 marb10" style=" padding-left:0; padding-right:0;">
            <div class="welcome-left-container col-lg-12">
                <div class="panel area-pad">
                    <div class="area-tit">问卷调查信息</div>
                    <div id="question" style="width:100%;height:308px;"></div>
                </div>
            </div>
        </div>
        <!--版本更新记录开始-->
        <div class="welcome-left-container col-lg-3 marb10">
            <div class="panel area-pad">
                <div class="area-tit">版本更新记录</div>
                <div class="bb-update-record" style="overflow: auto;color: #777"></div>
            </div>
        </div>
        <!--版本更新记录结束-->
    </div>
</div>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/lib/echarts/echarts.js"></script>
<script src="${s.base}/js/common.js"></script>
<script type="text/javascript">
    layui.use(['jquery', 'baseutil'], function () {
        var $ = layui.jquery,
            baseutil = layui.baseutil;

        var loginName = parent.document.getElementById("loginName").value;
        var applyId = parent.document.getElementById("applyId").value;
        var applyUseId = parent.document.getElementById("applyUseId").value;

        //头部统计
        baseutil.post('/work/site/notice/statisticsByType', {applyId: applyId}, function (result) {
            if (result.code === 0) {
                $('.menu-data').each(function (i) {
                    $(this).prepend(result.data[i]);
                });
            } else {
                $('.menu-data').each(function () {
                    $(this).prepend(0);
                });
            }
        });

        //资产报修信息
        baseutil.post('/work/asset/statisticsByMonth', {applyId: applyId}, function (result) {
            if (result.code === 0) {
                showEcharts('asset', '次', '次数', result.data[0], result.data[1]);
            } else {
                showEcharts('asset', '次', '次数', [], []);
            }
        });

        //问卷调查信息
        baseutil.post('/work/question/statisticsByMonth', {applyId: applyId}, function (result) {
            if (result.code === 0) {
                showEcharts('question', '次', '次数', result.data[0], result.data[1]);
            } else {
                showEcharts('question', '次', '次数', [], []);
            }
        });

        require.config({
            paths: {
                echarts: '../../lib/echarts'
            }
        });

        function showEcharts(id, formatter, data, category, value) {
            var req = [
                'echarts',
                'echarts/chart/bar',
                'echarts/chart/line',
                'echarts/chart/map'
            ];
            require(req, function (ec) {
                ec.init(document.getElementById(id)).setOption({
                    title: {
                        text: ''
                    },
                    grid: {
                        x: 41,
                        y: 35,
                        x2: 0,
                        y2: 25,
                        borderWidth: 1
                    },
                    tooltip: {
                        trigger: "item",
                        formatter: "{b} <br/>{a} : {c}" + formatter
                    },
                    legend: {
                        data: [data]
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            mark: {show: false},
                            dataView: {show: false, readOnly: false},
                            magicType: {show: false, type: ['line', 'bar']},
                            restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    calculable: true,
                    xAxis: [
                        {
                            type: 'category',
                            data: category,
                            axisLabel: {
                                interval: 0
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: data,
                            type: 'bar',
                            data: value,
                            markPoint: {
                                data: [
                                    {type: 'max', name: '最大值'},
                                    {type: 'min', name: '最小值'}
                                ]
                            },
                            itemStyle: {
                                emphasis: {
                                    barBorderRadius: 5
                                },
                                normal: {
                                    barBorderRadius: 5,

                                    color: '#41a8fc'
                                }
                            }
                        }
                    ]
                });
            });
        }

        //日历
        baseutil.post('/index/calendar', {}, function (result) {
            var str = '';
            if (result.code === 0) {
                var e = result.data;
                str += '<div class="div-calendar-month"><span>' + e.month + '</span><span>' + e.year + '</span></div>';
                str += '<div class="div-calendar-week">';
                str += '<ul>';
                for (var i = 0; i < e.dayList.length; i++) {
                    if (e.dayOfWeek === i) {
                        str += '<li class="checked">';
                    } else {
                        str += '<li>';
                    }
                    str += '<div class="weekname">' + e.dayList[i].weekname + '</div><div class="datelist">' + e.dayList[i].datelist + '</div></li>';
                }
                str += '</ul>';
                str += '</div>';
            }
            $('.div-calendar').append(str);
        });

        //登录日志
        baseutil.post('/sysLogLogin/page', {loginName: loginName, page: 1, limit: 4}, function (result) {
            var str = '';
            if (result.code === 0) {
                for (var i = 0; i < result.data.length; i++) {
                    var e = result.data[i];
                    str += '<li>';
                    if (isBlank(e.exitTime)) {
                        str += '<div class="div-text-line ellipsis">' + new Date(e.createTime).Format("yyyy-MM-dd hh:mm:ss") + '</div>';
                    } else {
                        str += '<div class="div-text-line ellipsis">' + new Date(e.createTime).Format("yyyy-MM-dd hh:mm:ss") + '--' + new Date(e.exitTime).Format("yyyy-MM-dd hh:mm:ss") + '</div>';
                    }
                    str += '<div class="div-text-line">系统登录成功，IP地址：' + e.operIp + '</div>';
                    if (e.operatorType === '1') {
                        str += '<div class="comp-log"><i class="iconfont">&#xe65f;</i></div>';
                    } else if (e.operatorType === '2') {
                        str += '<div class="comp-log"><i class="iconfont">&#xe760;</i></div>';
                    } else if (e.operatorType === '3') {
                        str += '<div class="comp-log"><i class="iconfont">&#xe65f;</i></div>';
                    }
                    str += '</li>';
                }
            }
            $('.loginLog-sm ul').html(str);
        });

        //版本更新
        baseutil.post('/wx/wxapplyuse/selectOne', {id: applyUseId}, function (result) {
            if (result.code === 0) {
                $('.bb-update-record').html(result.data.updateRecord);
            } else {
                $('.bb-update-record').html('');
            }
        });
    });
</script>
</body>
</html>